package com.ruoyi.miscfees.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.miscfees.domain.Miscfees;
import com.ruoyi.miscfees.service.IMiscfeesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公寓杂费管理Controller
 * 
 * @author ruoyi
 * @date 2024-10-08
 */
@RestController
@RequestMapping("/miscfees/miscfees")
public class MiscfeesController extends BaseController
{
    @Autowired
    private IMiscfeesService miscfeesService;

    /**
     * 查询公寓杂费管理列表
     */
    @PreAuthorize("@ss.hasPermi('miscfees:miscfees:list')")
    @GetMapping("/list")
    public TableDataInfo list(Miscfees miscfees)
    {
        startPage();
        List<Miscfees> list = miscfeesService.selectMiscfeesList(miscfees);
        return getDataTable(list);
    }

    /**
     * 导出公寓杂费管理列表
     */
    @PreAuthorize("@ss.hasPermi('miscfees:miscfees:export')")
    @Log(title = "公寓杂费管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Miscfees miscfees)
    {
        List<Miscfees> list = miscfeesService.selectMiscfeesList(miscfees);
        ExcelUtil<Miscfees> util = new ExcelUtil<Miscfees>(Miscfees.class);
        util.exportExcel(response, list, "公寓杂费管理数据");
    }

    /**
     * 获取公寓杂费管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('miscfees:miscfees:query')")
    @GetMapping(value = "/{FeeID}")
    public AjaxResult getInfo(@PathVariable("FeeID") Long FeeID)
    {
        return success(miscfeesService.selectMiscfeesByFeeID(FeeID));
    }

    /**
     * 新增公寓杂费管理
     */
    @PreAuthorize("@ss.hasPermi('miscfees:miscfees:add')")
    @Log(title = "公寓杂费管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Miscfees miscfees)
    {
        return toAjax(miscfeesService.insertMiscfees(miscfees));
    }

    /**
     * 修改公寓杂费管理
     */
    @PreAuthorize("@ss.hasPermi('miscfees:miscfees:edit')")
    @Log(title = "公寓杂费管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Miscfees miscfees)
    {
        return toAjax(miscfeesService.updateMiscfees(miscfees));
    }

    /**
     * 删除公寓杂费管理
     */
    @PreAuthorize("@ss.hasPermi('miscfees:miscfees:remove')")
    @Log(title = "公寓杂费管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{FeeIDs}")
    public AjaxResult remove(@PathVariable Long[] FeeIDs)
    {
        return toAjax(miscfeesService.deleteMiscfeesByFeeIDs(FeeIDs));
    }
}
